
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.CureMethod;
import cn.edu.scau.cmi.hombio.domain.CurePig;
import cn.edu.scau.cmi.hombio.domain.CureTaskCourse;
import cn.edu.scau.cmi.hombio.domain.CureTaskMethod;
import cn.edu.scau.cmi.hombio.domain.Task;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class CureTaskCourseServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected CureTaskCourseService service;

	/**
	 * Instantiates a new CureTaskCourseServiceTest.
	 *
	 */
	public CureTaskCourseServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Return all CureTaskCourse entity
	* 
	 */
	@Test
	public void findAllCureTaskCourses() {
		// TODO: JUnit - Populate test inputs for operation: findAllCureTaskCourses 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<CureTaskCourse> response = null;
		response = service.findAllCureTaskCourses(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllCureTaskCourses
	}

	/**
	 * Operation Unit Test
	* Save an existing CureTaskMethod entity
	* 
	 */
	@Test
	public void saveCureTaskCourseCureTaskMethods() {
		// TODO: JUnit - Populate test inputs for operation: saveCureTaskCourseCureTaskMethods 
		Integer id = 0;
		CureTaskMethod related_curetaskmethods = new cn.edu.scau.cmi.hombio.domain.CureTaskMethod();
		CureTaskCourse response = null;
		response = service.saveCureTaskCourseCureTaskMethods(id, related_curetaskmethods);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCureTaskCourseCureTaskMethods
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureMethod entity
	* 
	 */
	@Test
	public void deleteCureTaskCourseCureMethods() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureTaskCourseCureMethods 
		Integer curetaskcourse_id = 0;
		Integer related_curemethods_id = 0;
		CureTaskCourse response = null;
		response = service.deleteCureTaskCourseCureMethods(curetaskcourse_id, related_curemethods_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCureTaskCourseCureMethods
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureTaskMethod entity
	* 
	 */
	@Test
	public void deleteCureTaskCourseCureTaskMethods() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureTaskCourseCureTaskMethods 
		Integer curetaskcourse_id_1 = 0;
		Integer related_curetaskmethods_id = 0;
		CureTaskCourse response = null;
		response = service.deleteCureTaskCourseCureTaskMethods(curetaskcourse_id_1, related_curetaskmethods_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCureTaskCourseCureTaskMethods
	}

	/**
	 * Operation Unit Test
	* Return a count of all CureTaskCourse entity
	* 
	 */
	@Test
	public void countCureTaskCourses() {
		Integer response = null;
		response = service.countCureTaskCourses();
		// TODO: JUnit - Add assertions to test outputs of operation: countCureTaskCourses
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureTaskCourse entity
	* 
	 */
	@Test
	public void deleteCureTaskCourse() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureTaskCourse 
		CureTaskCourse curetaskcourse = new cn.edu.scau.cmi.hombio.domain.CureTaskCourse();
		service.deleteCureTaskCourse(curetaskcourse);
	}

	/**
	 * Operation Unit Test
	* Save an existing CureMethod entity
	* 
	 */
	@Test
	public void saveCureTaskCourseCureMethods() {
		// TODO: JUnit - Populate test inputs for operation: saveCureTaskCourseCureMethods 
		Integer id_1 = 0;
		CureMethod related_curemethods = new cn.edu.scau.cmi.hombio.domain.CureMethod();
		CureTaskCourse response = null;
		response = service.saveCureTaskCourseCureMethods(id_1, related_curemethods);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCureTaskCourseCureMethods
	}

	/**
	 * Operation Unit Test
	* Save an existing Task entity
	* 
	 */
	@Test
	public void saveCureTaskCourseTask() {
		// TODO: JUnit - Populate test inputs for operation: saveCureTaskCourseTask 
		Integer id_2 = 0;
		Task related_task = new cn.edu.scau.cmi.hombio.domain.Task();
		CureTaskCourse response = null;
		response = service.saveCureTaskCourseTask(id_2, related_task);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCureTaskCourseTask
	}

	/**
	 * Operation Unit Test
	* Load an existing CureTaskCourse entity
	* 
	 */
	@Test
	public void loadCureTaskCourses() {
		Set<CureTaskCourse> response = null;
		response = service.loadCureTaskCourses();
		// TODO: JUnit - Add assertions to test outputs of operation: loadCureTaskCourses
	}

	/**
	 * Operation Unit Test
	* Save an existing CurePig entity
	* 
	 */
	@Test
	public void saveCureTaskCourseCurePigs() {
		// TODO: JUnit - Populate test inputs for operation: saveCureTaskCourseCurePigs 
		Integer id_3 = 0;
		CurePig related_curepigs = new cn.edu.scau.cmi.hombio.domain.CurePig();
		CureTaskCourse response = null;
		response = service.saveCureTaskCourseCurePigs(id_3, related_curepigs);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCureTaskCourseCurePigs
	}

	/**
	 * Operation Unit Test
	* Save an existing CureTaskCourse entity
	* 
	 */
	@Test
	public void saveCureTaskCourse() {
		// TODO: JUnit - Populate test inputs for operation: saveCureTaskCourse 
		CureTaskCourse curetaskcourse_1 = new cn.edu.scau.cmi.hombio.domain.CureTaskCourse();
		service.saveCureTaskCourse(curetaskcourse_1);
	}

	/**
	 * Operation Unit Test
	* Delete an existing Task entity
	* 
	 */
	@Test
	public void deleteCureTaskCourseTask() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureTaskCourseTask 
		Integer curetaskcourse_id_2 = 0;
		Integer related_task_id = 0;
		CureTaskCourse response = null;
		response = service.deleteCureTaskCourseTask(curetaskcourse_id_2, related_task_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCureTaskCourseTask
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findCureTaskCourseByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findCureTaskCourseByPrimaryKey 
		Integer id_4 = 0;
		CureTaskCourse response = null;
		response = service.findCureTaskCourseByPrimaryKey(id_4);
		// TODO: JUnit - Add assertions to test outputs of operation: findCureTaskCourseByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Delete an existing CurePig entity
	* 
	 */
	@Test
	public void deleteCureTaskCourseCurePigs() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureTaskCourseCurePigs 
		Integer curetaskcourse_id_3 = 0;
		Integer related_curepigs_id = 0;
		CureTaskCourse response = null;
		response = service.deleteCureTaskCourseCurePigs(curetaskcourse_id_3, related_curepigs_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCureTaskCourseCurePigs
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
